var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        storeId: null,
        ordersn: "",
        couponMemberKwd: "",
        status: 0,
        isLoadMore: !0,
        page: 1,
        totalPage: 0,
        orderList: [],
        tabs: [ {
            name: "全部",
            status: 0
        }, {
            name: "待核销",
            status: 2
        }, {
            name: "退款订单",
            status: -1
        } ]
    },
    onLoad: function(t) {
        var a;
        "" !== (null !== (a = t.storeId) && void 0 !== a ? a : "") && (this.setData({
            storeId: parseInt(t.storeId)
        }), this.orderList());
    },
    modelInput: function(a) {
        console.log(a);
        var o = a.currentTarget.dataset.name, e = a.detail;
        this.setData(t({}, o, e));
    },
    onSearch: function() {
        this.orderList();
    },
    onTabChange: function(t) {
        var a = t.detail.name;
        console.log(t), this.setData({
            status: a
        }), this.orderList();
    },
    orderList: function() {
        var t = this, o = a.getNetAddresss("plugin.coupon-store.frontend.store-manage.orderList"), e = {
            cstore_id: this.data.storeId,
            coupon_member_kwd: this.data.couponMemberKwd,
            order_sn: this.data.ordersn,
            status: this.data.status,
            page: 1
        };
        a._postNetWork({
            url: o,
            data: e,
            success: function(a) {
                var o = a.data;
                wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == o.result ? (t.data.isLoadMore = !0, 
                t.data.totalPage = o.data.last_page, t.data.totalPage || (t.data.totalPage = 0), 
                t.setData({
                    orderList: o.data.data
                })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var o = a.getNetAddresss("plugin.coupon-store.frontend.store-manage.orderList"), e = {
                cstore_id: this.data.storeId,
                coupon_member_kwd: this.data.couponMemberKwd,
                order_sn: this.data.ordersn,
                status: this.data.status,
                page: 1
            };
            a._getNetWork({
                url: o,
                data: e,
                success: function(a) {
                    var o = a.data, e = o.data.data;
                    1 == o.result ? (t.data.isLoadMore = !0, t.setData({
                        orderList: t.data.orderList.concat(e)
                    })) : (t.data.page = t.data.page - 1, t.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onReady: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            page: 1,
            couponMemberKwd: "",
            ordersn: ""
        }), this.orderList();
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {}
});